package org.example.mybatisdemo.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.mybatisdemo.model.User;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user")
    List<User> selectAll() ;

    @Select("select * from user where id =#{id} ")
    User selectById(Integer id) ;

    @Insert("insert into user values (#{id},#{name},#{age})")
    int insert(User user);

    @Options(useGeneratedKeys = true,keyProperty = "id")//获取插入的自增id
    @Insert("insert into user (name,age) values (#{name},#{age})")
    Integer idOfInsert(User user);

    @Delete("delete from user where id =#{id}")
    int deleteById(Integer id);

    @Update("update user set age=#{age} where id =#{id}")
    int updateAgeById(Integer id, Integer age);
}
